package com.gb.models.main.utils;

import java.io.Serializable;
import java.util.HashMap;

/**
 * 全局返回
 *
 * @author liaosh
 * @version 1.0.0
 * @Date 2017/8/15 16:23
 */
public class ResultMsg implements Serializable {

    private static final long serialVersionUID = 1L;

    private static final Boolean SUCCESS = Boolean.TRUE;
    private static final Boolean ERROR = Boolean.FALSE;
    private static final String MESSAGE = "成功";

    //返回码
    private int msgCode;
    //返回信息
    private String message;
    //状态
    private Boolean state;
    //数据
    private Object data;

    //构造方法
    public ResultMsg() {
        state = SUCCESS;
        message = MESSAGE;
    }
    public ResultMsg (Object data){
        state = SUCCESS;
        message = MESSAGE;
        this.data = data;
    }
    public ResultMsg (Throwable e){
        state = ERROR;
        this.message = e.getMessage();
    }

    public ResultMsg (int code, Throwable e){
        state = ERROR;
        msgCode = code;
        this.message = e.getMessage();
    }
    public ResultMsg (String errorMsg){
        state = ERROR;
        this.message = errorMsg;
    }

    public int getMsgCode() {
        return msgCode;
    }

    public void setMsgCode(int msgCode) {
        this.msgCode = msgCode;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Boolean getState() {
        return state;
    }

    public void setState(Boolean state) {
        this.state = state;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "ResultMsg{" +
                "msgCode=" + msgCode +
                ", message='" + message + '\'' +
                ", state=" + state +
                ", data=" + data +
                '}';
    }
}
